import { request } from '@/utils/requestWrapper';
import { tokenStore } from "@/store/tokenStore";

const tokenStoreInstance = tokenStore();

/** 添加购物车 POST /api/cart/add */
export async function addCartUsingPost(
  body: API.CartAddRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseLong_>({
    url: "/api/cart/add",
    method: "POST",
    header: {
      'Authorization': tokenStoreInstance.getToken,
      'content-type': 'application/json'
    },
    data: body,
    ...options
  });
}

/** 删除购物车 POST /api/cart/delete */
export async function deleteCartUsingPost(
  body: API.DeleteRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseBoolean_>({
    url: "/api/cart/delete",
    method: "POST",
    header: {
      'Authorization': tokenStoreInstance.getToken,
      'content-type': 'application/json'
    },
    data: body,
    ...options
  });
}

/** 分页获取购物车列表 POST /api/cart/list/page/vo */
export async function listCartVoByPageUsingPost(
  body: API.CartQueryRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponsePageCartVO_>({
    url: "/api/cart/list/page/vo",
    method: "POST",
    header: {
      'Authorization': tokenStoreInstance.getToken,
      'content-type': 'application/json'
    },
    data: body,
    ...options
  });
}

/** 获取我的购物车列表 POST /api/cart/my/list/page/vo */
export async function listMyCartVoByPageUsingPost(
  body: API.CartQueryRequest,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponsePageCartVO_>({
    url: "/api/cart/my/list/page/vo",
    method: "POST",
    header: {
      'Authorization': tokenStoreInstance.getToken,
      'content-type': 'application/json'
    },
    data: body,
    ...options
  });
} 